<html>
<head>
    <title>iisnode logs</title>
    <style type="text/css">
        body
        {
            font-family: "Trebuchet MS" , Arial, Helvetica, sans-serif;
        }
        table
        {
            border-collapse: collapse;
        }
        td, th
        {
            border: 1px solid lightgray;
            padding: 3px 7px 2px 7px;
        }
        th
        {
            text-align: left;
            padding-top: 5px;
            padding-bottom: 4px;
            background-color: Gray;
            color: #ffffff;
        }
        td.stderr
        {
            color: Red;
        }
    </style>
</head>
<body>
    <table id="logFilesTable">
        <tr>
            <th>
                Computer name
            </th>
            <th>
                PID
            </th>
            <th>
                Type
            </th>
            <th>
                Created
            </th>
            <th>
                Link
            </th>
        </tr>
    </table>
    <p id="lastUpdated"></p>
    <script type="text/javascript">

        // this is replaced with actual data at runtime by code in interceptor.js
        var logFiles = [{"file":"YANGGS-PC-10884-stdout-1465035792399.txt","computername":"YANGGS-PC","pid":10884,"type":"stdout","created":1465035792399},{"file":"YANGGS-PC-11224-stdout-1465036666451.txt","computername":"YANGGS-PC","pid":11224,"type":"stdout","created":1465036666451},{"file":"YANGGS-PC-11716-stdout-1465029458268.txt","computername":"YANGGS-PC","pid":11716,"type":"stdout","created":1465029458268},{"file":"YANGGS-PC-12548-stdout-1465035380612.txt","computername":"YANGGS-PC","pid":12548,"type":"stdout","created":1465035380612},{"file":"YANGGS-PC-12696-stdout-1465035625147.txt","computername":"YANGGS-PC","pid":12696,"type":"stdout","created":1465035625147},{"file":"YANGGS-PC-12788-stdout-1465036555985.txt","computername":"YANGGS-PC","pid":12788,"type":"stdout","created":1465036555985},{"file":"YANGGS-PC-14080-stdout-1465036580340.txt","computername":"YANGGS-PC","pid":14080,"type":"stdout","created":1465036580340},{"file":"YANGGS-PC-3420-stdout-1465035417023.txt","computername":"YANGGS-PC","pid":3420,"type":"stdout","created":1465035417023},{"file":"YANGGS-PC-3712-stdout-1465036792447.txt","computername":"YANGGS-PC","pid":3712,"type":"stdout","created":1465036792447},{"file":"YANGGS-PC-5268-stdout-1465036416902.txt","computername":"YANGGS-PC","pid":5268,"type":"stdout","created":1465036416902}];
        var lastUpdated = 1465036792826;
        var date = new Date();

        date.setTime(lastUpdated);
        document.getElementById('lastUpdated').innerHTML = 'Index was last updated ' + date;

        logFiles.sort(function (a, b) {
            return b.created - a.created;
        });

        var logFilesTable = document.getElementById("logFilesTable");
        for (var i = 0; i < logFiles.length; i++) {
            var logFile = logFiles[i];
            date.setTime(logFile.created);
            var row = logFilesTable.insertRow(-1);
            var computerNameCell = row.insertCell(0);
            var pidCell = row.insertCell(1);
            var typeCell = row.insertCell(2);
            var dateCell = row.insertCell(3);
            var logCell = row.insertCell(4);
            computerNameCell.innerHTML = logFile.computername;
            pidCell.innerHTML = logFile.pid.toString();
            typeCell.innerHTML = logFile.type;
            typeCell.setAttribute('class', logFile.type);
            dateCell.innerHTML = date.toString();
            logCell.innerHTML = '<a href="' + logFile.file + '">log</a>';
        };

    </script>
</body>
</html>
